import datetime
from pydantic import BaseModel, EmailStr
from datetime import datetime


class TokenInfo(BaseModel):
    access_token: str
    token_type: str
    username: str


class UserBase(BaseModel):
    username: str
    email: EmailStr
    firstname: str | None = None
    lastname: str | None = None
    phone: str | None = None

    class ConfigDict:
        from_attributes = True
        arbitrary_types_allowed = True


class UserCreate(UserBase):
    password: str


class UserRead(UserBase):
    id: int
    hashed_password: bytes
    active: bool = False
    is_superuser: bool = False
    fullname: str | None = None
    registered_at: datetime


class UserResponse(BaseModel):
    id: int
    username: str
    email: EmailStr
